<template>
  <div class="proposal">
    <!-- <div :style="{height:'1px'}"></div> -->
    <public title="建议反馈"></public>
    <van-form @submit="onSubmit">
      <div class="proposal-public">
        <h4>问题类型</h4>
        <div class="proposal-selected">
          <van-field name="radio">
            <template #input>
              <van-radio-group v-model="radio" direction="horizontal">
                <van-radio name="1">功能异常</van-radio>
                <van-radio name="2">优化建议</van-radio>
              </van-radio-group>
            </template>
          </van-field>
        </div>
      </div>
      <div class="proposal-public">
        <h4 class="border">问题或建议</h4>
        <van-field
          name="text"
          v-model="message"
          rows="5"
          autosize
          type="textarea"
          maxlength="500"
          placeholder="请描述您的问题或建议，如果有系统截图，请添加图片中上传截图，我们将尽快优化体验，感谢您的反馈"
          show-word-limit
          :rules="[{ required: true, message: '内容不能为空',trigger: 'onBlur'}]"
        />
      </div>
      <div class="proposal-public">
        <h4>
          添加图片（选填）
          <span>文件大小不可以超过3M</span>
        </h4>
        <van-field name="upload">
          <template #input>
            <div class="proposal-upload">
              <van-uploader multiple :max-count="6" :max-size="3 * 1024 * 1024" v-model="fileList" />
            </div>
          </template>
        </van-field>
      </div>
      <div class="proposal-public">
        <h4 class="border">联系方式（选填）</h4>

        <van-field v-model="tel" type="tel" placeholder="请留下您的手机号码" name="tel" />
      </div>
      <div class="btn">
        <van-button type="info" size="large" native-type="submit">提交</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import Public from "@/components/public/Public";
export default {
  data() {
    return {
      radio: "1",
      message: "",
      tel: "",
      fileList: []
    };
  },
  methods: {
    onSubmit(val) {
      console.log(val);
      this.$toast.success("反馈成功")
      this.radio = "1"
      this.message = ""
      this.tel = ""
      this.fileList = []
    }
  },
  components: {
    Public
  }
};
</script>

<style scoped lang="less">
/deep/.van-form {
  position: static;
  transform: none;
  width: auto;
}
.proposal {
  background: #f4f4f4;
}
.btn {
  margin: 15px;
  .van-button {
    border-radius: 5px;
  }
}
.proposal-public {
  background: #fff;
  padding: 10px;
  margin-bottom: 10px;
  /deep/.van-field__control::placeholder {
    color: #999;
  }
  h4 {
    margin: 0;
    font-size: 16px;
    font-weight: normal;
    padding-bottom: 10px;
    &.border {
      border-bottom: 1px solid #eaeaea;
    }
    span {
      color: #999;
      font-size: 12px;
    }
  }
  .proposal-selected {
    /deep/.van-radio__label {
      font-size: 14px;
    }
  }
  .van-cell {
    padding: 10px 0;
  }
  .proposal-upload {
    /deep/.van-uploader__preview {
      margin-right: 15px;
      margin-bottom: 10px;
    }
  }
}
</style>